home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20021006-20030409 / 000119_mswarbrick@rentokil.com_Mon Dec 2 10:47:33 EST 2002.msg < prev    next >
Text File  |  2020-01-01  |  3KB  |  88 lines

  1. Article: 13900 of comp.protocols.kermit.misc
  2. Path: newsmaster.cc.columbia.edu!panix!newsfeed.media.kyoto-u.ac.jp!logbridge.uoregon.edu!newsfeed.stanford.edu!postnews1.google.com!not-for-mail
  3. From: mswarbrick@rentokil.com (Mark Swarbrick)
  4. Newsgroups: comp.protocols.kermit.misc
  5. Subject: sms modem issues revisited
  6. Date: 2 Dec 2002 07:40:26 -0800
  7. Organization: http://groups.google.com/
  8. Lines: 70
  9. Message-ID: <e516d9ec.0212020740.396d532b@posting.google.com>
  10. NNTP-Posting-Host: 213.2.66.194
  11. Content-Type: text/plain; charset=ISO-8859-1
  12. Content-Transfer-Encoding: 8bit
  13. X-Trace: posting.google.com 1038843626 5424 127.0.0.1 (2 Dec 2002 15:40:26 GMT)
  14. X-Complaints-To: groups-abuse@google.com
  15. NNTP-Posting-Date: 2 Dec 2002 15:40:26 GMT
  16. Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:13900
  17.  
  18. Hi guys..
  19.  
  20. I posted a while back asking for some help with communicating with an
  21. sms modem via kermit. I haven't really refined the kermit scripts at
  22. all since then. However I had to do another project based around
  23. nagios (previously netsaint) for service monitoring.. I have written a
  24. little hack to sms users when services go down using kermit. Though it
  25. might be usual to someone (do let me know.) I suppose it might be
  26. better in a nagios newsgroup but it's sorta a bit of both, so don't
  27. flame me ok!?
  28.  
  29. In the nagios config file define the external handler to use
  30.  
  31. ------
  32. define command{
  33.         command_name    sms_alert
  34.         command_line   
  35. /usr/local/nagios/libexec/event_handlers/sms_alert  $SE\
  36. RVICESTATE$ $STATETYPE$ $SERVICEATTEMPT$ $HOSTNAME$ $HOSTADDRESS$
  37. $SERVICEDESC$\
  38.  $SERVICESTATE$ $DATE$ $TIME$
  39. -----
  40. Then create the event handler itself
  41.  
  42. #!/bin/sh
  43.  
  44. message(){
  45.     dir="/usr/local/nagios/libexec/event_handlers"
  46.     touch $dir/sms_message.msg
  47.     echo lineout AT+CMGS="+447747603208" >>$dir/sms_message.msg
  48.     echo input 20 >>$dir/sms_message.msg
  49.     echo lineout On $1 $2 the status of service $3 is $4 $5 $6
  50. >>$dir/sms_message.msg
  51.     echo output \\26 >>$dir/sms_message.msg
  52.     echo input 20 ok >>$dir/sms_message.msg
  53.  
  54.     mv $dir/sms_message.msg /tmp/outbox
  55.  
  56. }
  57.  
  58. # What state is the service in?
  59. case "$1" in
  60. OK)
  61.  
  62.         ;;
  63. WARNING)
  64.  
  65.         ;;
  66. CRITICAL)
  67.         if [ "$3" == "3" ] ;
  68.         then
  69.             message $4 $5 $6 $7 $8 $9 ;
  70.         fi
  71.         ;;
  72.  
  73. UNKNOWN)
  74.         if [ "$3" == "3" ] ;
  75.         then
  76.             message $4 $5 $6 $7 $8 $9 ;
  77.         fi
  78.         ;;
  79. esac
  80. exit 0
  81.  
  82. -------
  83.  
  84. This sms_message.msg can then be passed and processed via a kermit
  85. kerbang script which just connects to the port and sends the message.
  86. I couldn't find a simple solution to this, so I figured it might help
  87. someone..
  88.